package com.woniu.controller;



import com.woniu.entity.PageResult;
import com.woniu.entity.Result;
import com.woniu.service.ISignService;
import com.woniu.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author doujiao
 * @since 2022-10-14
 */
@RestController
@RequestMapping("/sign")
@Api(tags = "签约模块")
public class SignController extends BaseController{

    @Resource
    private ISignService signService;
    /**
     * 根据条件分页查询
     */
    @PostMapping("/search/sign/{currentPage}/{pageSize}")
    @ApiOperation("根据条件分页查询签约")
    public Result queryByPage(@PathVariable Long currentPage, @PathVariable Long pageSize,
                              @RequestBody QuerySignVo querySignVo){
        PageResult pageResult= signService.queryByPage(currentPage,pageSize,querySignVo);
        return toDataResult(pageResult);

    }
    /**
     * 根据id查询
     */
    @GetMapping("/{id}")
    @ApiOperation("根据id查询签约")
    public Result queryById(@PathVariable Long id){
       SignVo signVo= signService.queryById(id);
       return toDataResult(signVo);
    }
    /**
     * 编辑
     *
     */
    @PutMapping
    @ApiOperation("编辑签约")
    public Result edit(@RequestBody SignEditVo signEditVo){
       Boolean flag = signService.edit(signEditVo);
       return toResult(flag);
    }
    /**
     *签约记录分页查找
     */
    @PostMapping("/search/record/{currentPage}/{pageSize}")
    @ApiOperation("根据条件分页查询签约记录")
    public Result queryRecordByPage(@PathVariable Long currentPage, @PathVariable Long pageSize,
                                    @RequestBody QuerySignRecordVo querySignRecordVo){
       PageResult pageResult= signService.queryRecordByPage(currentPage,pageSize,querySignRecordVo);
       return toDataResult(pageResult);
    }
    @GetMapping("/record/{id}")
    @ApiOperation("根据id查询签约记录record")
    public Result queryRecordById(@PathVariable Long id){
        SignRecordVo signRecordVo= signService.queryRecordById(id);
        return toDataResult(signRecordVo);
    }
    /**
     * 编辑record
     */
    @PutMapping("/record")
    @ApiOperation("编辑签约记录record")
    public Result editRecord(@RequestBody SignRecordEditVo signRecordEditVo){
         Boolean flag= signService.editRecord(signRecordEditVo);
         return toResult(flag);
    }
    /**
     * 审核通过
     */
    @PutMapping("/audit")
    @ApiOperation("审核通过")
     public Result passAudit(@RequestBody SignRecordEditVo signRecordEditVo){
        Boolean flag= signService.passAudit(signRecordEditVo);
        return toResult(flag);
     }
    /**
     * 驳回
     */
    @PutMapping("/refuse")
    public Result refuse(@RequestBody  SignRecordEditVo signRecordEditVo){
       Boolean flag= signService.refuse(signRecordEditVo);
       return toResult(flag);
    }
}

